package top.lingkang.securityoauth2.client.http;

import org.springframework.beans.factory.annotation.Autowired;
import top.lingkang.securityoauth2.client.config.Oauth2ClientProperties;
import top.lingkang.securityoauth2.client.utils.GenerateUtils;

import javax.servlet.http.HttpSession;
import java.util.HashMap;

/**
 * @author lingkang
 * Created by 2022/1/7
 * FinalSecurity 开放方法（核心）
 */
public class SecurityOauth2Holder {
    @Autowired
    private Oauth2ClientProperties clientProperties;

    public void login(String username, String password) {
        HashMap<String, Object> param = GenerateUtils.getClientBase(clientProperties);
        param.put("username", username);
        param.put("password", password);
        param.put("grant_type", "password");
        clientProperties.getHttpRequest().post("/oauth2/token", param, null);
    }

    public void logout() {
        HttpSession session = FinalSecurityContext.getRequest().getSession();
    }

    public String[] getRole() {
        return null;
    }

    public String getUsername() {
        return null;
    }

    public boolean isLogin() {
        return false;
    }
}
